package com.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 学院 ： 要管理系 Department
 */
public class College extends OrganizationComponent{

    private List<OrganizationComponent> departments = new ArrayList<>();

    public College(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        departments.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        departments.remove(organizationComponent);
    }

    @Override
    protected void print() {
        System.out.println("----------"+getName()+"--------");
        //下面其实是遍历其直接下属部门
        departments.forEach(department ->  {
            department.print();
        });
    }
}
